<?php
    /**
     * Elgg custom index layout
     *
     * You can edit the layout of this page with your own layout and style.
     * Whatever you put in this view will appear on the front page of your site.
     *
     */

    $mod_params = array('class' => 'elgg-module-highlight');

?>

<div class="custom-index elgg-main elgg-grid clearfix">

    <div class="elgg-col elgg-col-1of2">
        <div class="elgg-inner pvm prl">

            <div class="et-module-message">
                <?php include elgg_get_data_path() . "easytheme/intro.php"; ?>

            </div>

            <?php
// left column
// a view for plugins to extend
            echo elgg_view("index/lefthandside");

            echo elgg_view_module('featured', elgg_echo("custom:members"), $vars['members'], $mod_params);

// groups
            if (elgg_is_active_plugin('groups')) {
                echo elgg_view_module('featured', elgg_echo("custom:groups"), $vars['groups'], $mod_params);
            }

// blogs
            if (elgg_is_active_plugin('blog')) {
                echo elgg_view_module('featured', elgg_echo("custom:blogs"), $vars['blogs'], $mod_params);
            }

            if (elgg_is_active_plugin('questions')) {
                echo elgg_view_module('featured', elgg_echo("custom:questions"), $vars['questions'], $mod_params);
            }

            ?>

        </div>
    </div>
    <div class="elgg-col elgg-col-1of2-alt">
        <div class="elgg-inner pvm">

            <?php

            // Top box for login or welcome message
            if (elgg_is_logged_in()) {

                $user = elgg_get_logged_in_user_entity();

                if ($user) {
                    $icon = elgg_view_entity_icon($user, 'medium', array(
                        'use_hover' => false,
                        'use_link' => false,
                    ));
                }
                $top_box .= "<div>";
                $top_box = '<h2 style="float:left;">' . elgg_echo("welcome") . ' ';
                $top_box .= elgg_get_logged_in_user_entity()->name;
                $top_box .= "</h2>";
                $top_box .= '<div style="display: inline-block; float: right;">' . $icon . '</div>';
                $top_box .= "</div>";
                $top_box .= '<div style="float:left;">';
                $baseurl = elgg_get_site_url();
                $top_box .= '<a class="elgg-button elgg-button-action" style="width: 120px; margin-left: 10px; margin-bottom: 10px; float: left; " href="' . $baseurl . 'profile/' . $user->username . '">' . elgg_echo('custom:profile') . '</a>';
                $top_box .= '<a class="elgg-button elgg-button-action" style="width: 120px; margin-left: 10px; margin-bottom: 10px; float: left; " href="' . $baseurl . 'messages/inbox/' . $user->username . '">' . elgg_echo('custom:message') . '</a>';
                $top_box .= '<a class="elgg-button elgg-button-action" style="width: 120px; margin-left: 10px; margin-bottom: 10px; float: left; " href="' . $baseurl . 'friends/' . $user->username .'">' . elgg_echo('custom:friend') . '</a>';
                $top_box .= '<a class="elgg-button elgg-button-action" style="width: 120px; margin-left: 10px; margin-bottom: 10px; float: left; " href="' . $baseurl . 'groups/all?filter=discussion' . '">' . elgg_echo('custom:group') . '</a>';
                $top_box .= '<a class="elgg-button elgg-button-action" style="width: 120px; margin-left: 10px; margin-bottom: 10px; float: left; " href="' . $baseurl . 'questions/add/' . $user->username .'">' . elgg_echo('custom:question') . '</a>';
                $top_box .= '<a class="elgg-button elgg-button-action" style="width: 120px; margin-left: 10px; margin-bottom: 10px; float: left; " href="' . $baseurl . 'blog/add/' . $user->username .'">' . elgg_echo('custom:blog') . '</a>';
                $top_box .= "</div>";

            } else {
                $top_box = $vars['login'];
            }

            echo elgg_view_module('featured', '', $top_box, $mod_params);

            ?>

            <?php

// a view for plugins to extend
            echo elgg_view("index/righthandside");

            if (elgg_is_active_plugin('thewire')) {
                echo elgg_view_module('featured', elgg_echo("custom:wires"), $vars['wires'], $mod_params);
            }

            if (elgg_is_active_plugin('pages')) {
                echo elgg_view_module('featured', elgg_echo("custom:pages"), $vars['pages'], $mod_params);
            }

            // files
            if (elgg_is_active_plugin('file')) {
                echo elgg_view_module('featured', elgg_echo("custom:files"), $vars['files'], $mod_params);
            }

// bookmarks
            if (elgg_is_active_plugin('bookmarks')) {
                echo elgg_view_module('featured', elgg_echo("custom:bookmarks"), $vars['bookmarks'], $mod_params);
            }

            ?>

        </div>
    </div>
</div>
